home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!wbriscoe.demon.co.uk
- From: walter briscoe <walter@wbriscoe.demon.co.uk>
- Newsgroups: comp.std.c
- Subject: Re: Close all opened files in C ?
- Date: Fri, 29 Mar 96 13:17:38 GMT
- Message-ID: <828105458snz@wbriscoe.demon.co.uk>
- References: <4jgifa$fjd@chaos.kulnet.kuleuven.ac.be>
- Reply-To: walter@wbriscoe.demon.co.uk
- X-NNTP-Posting-Host: wbriscoe.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.30
- X-Mail2News-Path: wbriscoe.demon.co.uk
-
- In article <4jgifa$fjd@chaos.kulnet.kuleuven.ac.be>
- christian.felique@student.kuleuven.ac.be "christian felique" writes:
-
- > I am using a shareware C routine to play a sound sample
- > throught the PC speaker.
- >
- > SoundPlay("SAMPLE.VOC",delay,twiddle);
- >
- >
- > I think that the programmer
- > of the routine has forgotten to take care of closing the sample file
- > after it is played, because the routine will not work anymore after a few
- > calls (about 10 calls) (It displays an Out of Memory message)
- >
- > I think that the Out of Memory error has got nothing to
- > do with the size of a sound sample file, because:
- >
- > * You can call the routine for about 10 times using a small sample.
- > * " " " " " """"""""""""""10 """"""""""""large """""""
- >
- > According to me, the reason for the out of memory error
- > is the fact that there are too many file buffers open .
- >
- >
- > NOW THIS IS MY QUESTION:
- >
- > How can I close all files that are opened ?
- >
- > I can't use fclose(...) because fclose needs a file pointer as
- > an argument.
- >
- > If you know how to solve this problem in Quick C or
- > inline assembly. Then send me your answer
- > to:
-
- This thread is inappropriate in comp.std.c.
-
- Not as inappropriate as the "help wanted" threads which recently
- appeared and I ignored those.
-
- I suggest comp.lang.c.moderated may be appropriate.
-
- My first thought was that fclose ( 0 ) should do the job by analogy with
- fflush ( 0 ) but the standard library is not orthogonal.
-
- I don't know quickc's limitations but in Borland C++ 3.1 can:
-
- #include <stdio.h> or #include <io.h>
- (void)fcloseall int i = 6; while (!close(i++));
-
- or the assembly to close a file with a given handle is:
- mov bx, Handle ; Handle of file or device
- mov ah, 3Eh ; Close File with Handle
- int 21h ; Do it
- jc error_handler ; carry set on error
-
- ax contains a standard DOS error code on failure.
- --
- walter briscoe
-